<extend name="Public/base" />

<block name="body">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title cf">
        <h2>新增 [游戏]</h2>
    </div>
    <!-- 标签页导航 -->
<div class="tab-wrap">
    <ul class="tab-nav nav">
        <li data-tab="tab1" class="current"><a href="javascript:void(0);">基础</a></li>
    </ul>
    <div class="tab-content zc_for">
    <!-- 表单 -->
    <form id="form" action="{:U('edit?model='.$model['id'])}" method="post" class="form-horizontal">
        <!-- 基础 -->
        <div id="tab1" class="tab-pane in tab1">
            <table  border="0" cellspacing="0" cellpadding="0">
                <tbody>
                  <tr>
                    <td class="l">游戏类型名称：</td>
                    <td class="r" colspan='3'>
                        <input type="text" class="txt txt_title" name="type_name" value="{$data['type_name']}" placeholder="请输入游戏类型名称">
                    </td>
                  </tr>                  
                  <tr>
                    <td class="l">类型图标：</td>
                    <td class="r">
                        <input type="file" id="upload_picture_icon">
                        <input type="hidden" name="icon" id="cover_id_icon" value="{$data.icon}" />
                        <div class="upload-img-box">
                        <notempty name="data['icon']">
                            <div class="upload-pre-item"><img src="{$data['icon']|get_cover='path'}"/></div>
                        </notempty>
                        </div>
                    </td>
                    <td class="l">类型封面：</td>
                    <td class="r">
                        <input type="file" id="upload_picture_cover">
                        <input type="hidden" name="cover" id="cover_id_cover" value="{$data.cover}" />
                        <div class="upload-img-box">
                        <notempty name="data['cover']">
                            <div class="upload-pre-item"><img src="{$data['cover']|get_cover='path'}"/></div>
                        </notempty>
                        </div>
                    </td>                        
                    </td>
                  </tr>
                  <tr>
                    <td class="l">启用状态：</td>
                    <td class="r">
                        <label class="inp_radio">
                            <input type="radio" class="inp_radio" value="0" name="status_show" <eq name="data['status_show']" value="0">checked="checked"</eq> >禁用
                            <input type="radio" class="inp_radio" value="1" name="status_show" <eq name="data['status_show']" value="1">checked="checked"</eq> >启用
                        </label>
                    </td>
                    <td class="l"></td>
                    <td class="r">
                        
                    </td>
                  </tr>
                </tbody>
            </table>
        </div>
        <div class="form-item cf">
            <input type="hidden" name="id" value="{$data.id}">
            <button class="btn submit-btn ajax-post hidden" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <a class="btn btn-return" href="javascript:history.back(-1);">返 回</a>
        </div>
    </form>
    </div>
</div>
</block>

<block name="script">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('GameType/lists')}');
$('#submit').click(function(){
    $('#form').submit();
});

$(function(){
    $('.date').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    $('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    showTab();

});

//上传游戏图标
/* 初始化上传插件 */
$("#upload_picture_icon").uploadify({
    "height"          : 30,
    "swf"             : "__STATIC__/uploadify/uploadify.swf",
    "fileObjName"     : "download",
    "buttonText"      : "上传图标",
    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
    "width"           : 120,
    'removeTimeout'   : 1,
    'fileTypeExts'    : '*.jpg; *.png; *.gif;',
    "onUploadSuccess" : upload_picture_icon{$field.name},
    'onFallback' : function() {
        alert('未检测到兼容版本的Flash.');
    }
});
function upload_picture_icon{$field.name}(file, data){
    var data = $.parseJSON(data);
    var src = '';
    if(data.status){
        $("#cover_id_icon").val(data.id);
        src = data.url || '__ROOT__' + data.path;
        $("#cover_id_icon").parent().find('.upload-img-box').html(
            '<div class="upload-pre-item"><img src="' + src + '"/></div>'
        );
    } else {
        updateAlert(data.info);
        setTimeout(function(){
            $('#top-alert').find('button').click();
            $(that).removeClass('disabled').prop('disabled',false);
        },1500);
    }
}


//上传游戏封面
/* 初始化上传插件 */
$("#upload_picture_cover").uploadify({
    "height"          : 30,
    "swf"             : "__STATIC__/uploadify/uploadify.swf",
    "fileObjName"     : "download",
    "buttonText"      : "上传封面",
    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
    "width"           : 120,
    'removeTimeout'   : 1,
    'fileTypeExts'    : '*.jpg; *.png; *.gif;',
    "onUploadSuccess" : upload_picture_cover{$field.name},
    'onFallback' : function() {
        alert('未检测到兼容版本的Flash.');
    }
});
function upload_picture_cover{$field.name}(file, data){
    var data = $.parseJSON(data);
    var src = '';
    if(data.status){
        $("#cover_id_cover").val(data.id);
        src = data.url || '__ROOT__' + data.path;
        $("#cover_id_cover").parent().find('.upload-img-box').html(
            '<div class="upload-pre-item"><img src="' + src + '"/></div>'
        );
    } else {
        updateAlert(data.info);
        setTimeout(function(){
            $('#top-alert').find('button').click();
            $(that).removeClass('disabled').prop('disabled',false);
        },1500);
    }
}
</script>
</block>
